package com.ruoyi.energy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.energy.domain.TcInoutLog;
import com.ruoyi.energy.service.ITcInoutLogService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 回调日志Controller
 *
 * @author cjie
 * @date 2021-12-02
 */
@Api(tags = " 回调日志")
@RestController
@RequestMapping("/tcInoutLog")
public class TcInoutLogController extends BaseController {
    @Autowired
    private ITcInoutLogService tcInoutLogService;

    /**
     * 查询回调日志列表
     */
    @ApiOperation(value="查询回调日志列表", notes="查询回调日志列表")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:list")
    @GetMapping("/list")
    public TableDataInfo list(TcInoutLog tcInoutLog) {
        startPage();
        List<TcInoutLog> list = tcInoutLogService.selectTcInoutLogList(tcInoutLog);
        return getDataTable(list);
    }

    /**
     * 导出回调日志列表
     */
    @ApiOperation(value="导出回调日志列表", notes="导出回调日志列表")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:export")
    @Log(title = "回调日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TcInoutLog tcInoutLog) throws IOException {
        List<TcInoutLog> list = tcInoutLogService.selectTcInoutLogList(tcInoutLog);
        ExcelUtil<TcInoutLog> util = new ExcelUtil<TcInoutLog>(TcInoutLog.class);
        util.exportExcel(response, list, "回调日志数据");
    }
    /**
     * 获取回调日志详细信息
     */
    @ApiOperation(value="获取回调日志详细信息", notes="获取回调日志详细信息")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tcInoutLogService.selectTcInoutLogById(id));
    }

    /**
     * 新增回调日志
     */
    @ApiOperation(value="新增回调日志", notes="新增回调日志")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:add")
    @Log(title = "回调日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcInoutLog tcInoutLog) {
        return toAjax(tcInoutLogService.insertTcInoutLog(tcInoutLog));
    }

    /**
     * 修改回调日志
     */
    @ApiOperation(value="修改回调日志", notes="修改回调日志")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:edit")
    @Log(title = "回调日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcInoutLog tcInoutLog) {
        return toAjax(tcInoutLogService.updateTcInoutLog(tcInoutLog));
    }

    /**
     * 删除回调日志
     */
    @ApiOperation(value="删除回调日志", notes="删除回调日志")
    @ApiImplicitParam(name = "ids", value = "回调日志ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:tcInoutLog:remove")
    @Log(title = "回调日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tcInoutLogService.deleteTcInoutLogByIds(ids));
    }
}
